#!/bin/sh

if [ $# -eq 1 ]; then
    exec <$1
elif [ $# -ne 0 ]; then
    echo $(basename $0) [ licence_key_file ] 1>&2
    exit 1
fi

read licence_key

rm -rf GeoLite2-ASN-CSV_*

wget -q -OGeoLite2-ASN-CSV.zip "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-ASN-CSV&license_key=${licence_key}&suffix=zip"
unzip -q GeoLite2-ASN-CSV.zip
rm -f GeoLite2-ASN-CSV.zip
